package planit.model;

import java.util.ArrayList;
import java.io.Serializable;

public class Group implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Integer lastIdUsed;
	private int id;
	private String name;
	private String description;
	private ArrayList<Person> personList = new ArrayList<Person>();

	private Group() {
		if (lastIdUsed == null) {
			lastIdUsed = 0;
		}
		id = ++lastIdUsed;
		personList = new ArrayList<Person>();
	}

	public Group(int id, String name, String description, ArrayList<Person> persons) {
		this.id = id;
		Group.lastIdUsed = id;
		setDescription(description);
		addPersons(persons);
		setName(name);
	}

	public Group(String name){
		this();
		setName(name);
	}

	public void setName(String name){
		this.name = name;
	}
	public String getName(){
		return name;
	}
	public int getId(){
		return id;
	}
	public void addPerson(Person person){
		personList.add(person);
	}

	public void removePerson(Person person){
		personList.remove(person);
	}

	public void addPersons(ArrayList<Person> persons){
		personList.addAll(persons);
	}
	public void addPersons(Group g){
		personList.addAll(g.getPersons());
	}


	public ArrayList<Person> getPersons(){
		return personList;
	}

	public void setDescription(String description){
		this.description = description;
	}

	public String getDescription(){
		return description; 
	}
}
